<?php

use app\assets\TableAsset;
use app\widgets\ManagerTableOp;
use yii\helpers\Html;
use yii\helpers\Url;

/**
 * @var $this yii\web\View
 * @var $packageList app\models\Package[]
 */

TableAsset::register($this);

$this->title = '套餐列表';
$this->params['breadcrumbs'][] = '物联网卡管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo Html::beginForm('?', 'get', ['class'=>'form-inline']);?>
<div class="form-group">
    <a href="<?php echo Url::to(['/admin/card/package-edit']);?>" class="btn btn-success btn-sm">添加</a>
</div>
<?php echo Html::endForm();?>
<table class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th class="center">
                <label class="pos-rel">
                    <input type="checkbox" class="ace" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th>名称</th>
            <th>流量</th>
            <th>价格</th>
            <th>操作</th>
        </tr>
    </thead>

    <tbody>
        <?php foreach ($packageList as $package) {?>
            <tr>
                <td class="center"><label class="pos-rel"><input type="checkbox" class="ace" value="<?php echo $package->id;?>" /><span class="lbl"><?php echo $package->id;?></span></label></td>
                <td><?php echo Html::encode($package->name);?></td>
                <td><?php echo Yii::$app->formatter->asShortSize($package->data);?></td>
                <td><?php echo $package->price;?></td>
                <td><?php echo ManagerTableOp::widget(['items' => [
                        ['icon' => 'fa fa-pencil', 'href' => Url::to(['/admin/card/package-edit', 'id' => $package->id]), 'btn_class' => 'btn btn-xs btn-success', 'tip' => '修改', 'color' => 'green'],
                    ]]);?></td>
            </tr>
        <?php }?>
    </tbody>
</table>
